@extends('layouts.admin')
@section('style')
@endsection
@section('content')
    <div class="admin_main">
        <div class="admin_header_fixed">
            <div class="admin_header clearfix">
                <div class="title"><i></i>角色列表</div>
                <div class="action">
                    <b></b>
                    <div class="layui-btn-group ">
                        <a class="layui-btn layui-btn-primary layui-btn-small create" data-title="新增角色" data-icon="fa-plus-circle" href="{{ url('role/create') }}"><i class="fa fa-plus-circle"></i> 新增</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="admin_base">
            <div class="admin_module clearfix admin_module_search">
                <i class="line"></i>
                <a class="javascript" id="list_search_toggle" data-search-box="list_search" rel='list_search_switch'>关闭搜索</a>
                <div id="list_search" class="clearfix" >
                    <form  action="{{ url('role') }}"  id="RoleForm"   class="layui-form layui-form-pane" novalidate="1">
                       <div clss="layui-inline">
                            <div class="layui-form-item">
                                <div class="layui-input-inlinen">
                                    <select name="opt_type" style="width:auto">
                                        <option value="name" @if($opt_type=='name') selected @endif >角色标识</option>
                                        <option value="display_name" @if($opt_type=='display_name') selected @endif >显示名称</option>
                                        <option value="description" @if($opt_type=='description') selected @endif>角色描述</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-inline">
                                    <input type="text" name="keywords" value="{{ $keywords }}" id="keywords" placeholder="请填写关键词"  class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-inline">
                                    <button class="layui-btn" lay-submit lay-filter="btn_query" >查询</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="box_list">
                <div class="box_content">
                    <form method="post" action=""  id="list_form"   class="layui-form" novalidate="1">
                        {{ csrf_field() }}
                        <table class="layui-table list" lay-skin="row" lay-even="true" lay-filter="list">
                            <colgroup>
                                <col width="59"/>
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>角色标识</th>
                                    <th>角色名称</th>
                                    <th>角色描述</th>
                                    <th class="item_action">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($datas as $vo)
                                    <tr>
                                        <td>{{ $vo->id }}</td>
                                        <td>{{ $vo->name }}</td>
                                        <td>{{ $vo->display_name }}</td>
                                        <td>{{ $vo->description }}</td>
                                        <td class="item_action">
                                            <div class="layui-table-cell laytable-cell-1-8">
                                                <a class="layui-btn layui-btn-xs layui-btn-default" href="{{ url('role/'.$vo->id.'/permission') }}">授权</a>
                                                <a class="layui-btn layui-btn-xs layui-btn-primary" href="{{ url('role/'.$vo->id.'/edit') }}">编辑</a>
                                                <a class="layui-btn layui-btn-xs layui-btn-danger J-item-delete" data-id="{{ $vo->id }}" href="{{ url('role/'.$vo->id) }}">删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </form>
                </div>
                <div class="page-box">
                    <div id="pageShow"></div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
    <script type="text/javascript">
        var layForm;
        var count =parseInt("{{ $counts }}");
        var limit =parseInt("{{ $limit }}");
        var currPage =parseInt("{{ $page }}");
        layui.use(['form','element','layer','utils','xmPage'], function(){
            layForm = layui.form;
            var URL = layui.utils.URL;
            var xmPage = layui.xmPage({
                formElem:'#RoleForm',
                limit:limit,
                count:count,
                curr:currPage,
                layout:['prev','page','next','skip','count','limit'],
                prev:'<i class="fa fa-arrow-left"></i>',
                next:'<i class="fa fa-arrow-right"></i>',
            });
            xmPage.render();

            layForm.on('submit(btn_query)',function(data){
                $("#page").val(1);
                $(data.form).submit();
            })
        });
    </script>
@endsection